home *** CD-ROM | disk | FTP | other *** search
- /* Script Arexx pour jouer des fichiers midi dans dopus5
- (C)1998 Raistlin
- Version 1.0
-
- Usage : DOpus5:ARexx/Playmidi.dopus5 {f} {Qp}
- No flags
- */
-
- parse arg '"' file '"' portname .
-
- if portname='' then
- portname='DOPUS.1'
- address value portname
-
- cuthere=lastpos('/',file)
- if cuthere=0 then
- cuthere=pos(':',file)
- name=""substr(file,cuthere+1)""
-
- if ~show('l','rexxsupport.library') then
- call addlib('rexxsupport.library',0,-30)
-
- options results
-
- lister query source
- Handle = result
-
- lister set handle busy on
-
- address command 'GM:'
- address command 'Run >T:gmplay <NIL: gm:GMPLAY <NIL: >PIPE:gm-output' file
-
- lister set handle newprogress info bar abort
- lister set handle newprogress title 'Playing 'name' ...'
- lister set handle newprogress info 'Loading Instruments ...'
-
- open('temp','T:gmplay','r')
-
- process = readln('temp')
- parse var process '[CLI ' process ']'
- close('temp')
- call delete('T:gmplay')
-
- buffer=''
- open('gm','PIPE:gm-output','r')
- timer=0
- measure=0
- percent=0
- ended=0
-
- do until ended > 0
- buffer=buffer||readch('gm',15)
- new=verify(buffer,'%','m')
- ended=pos('Finished',buffer)
-
- lister query handle abort
- if result then do
- address command 'Break' process 'C'
- lister clear handle progress
- lister set handle busy off
- call close('gm')
- exit
- end
-
- if new >0 then do /* check for new line */
- line=left(buffer,new-1)
- buffer=substr(buffer,new+1)
-
- pos0=pos('Time',line)
- pos1=pos('Meas',line)
- pos2=pos('Perc',line)
-
- if pos0 + pos1 + pos2 ~= 0 then do
- timer = substr(line,pos0+5,5)
- measure = substr(line,pos1+8,pos2-pos1-8)
- percent = substr(line,pos2+11,3)
-
- lister set handle newprogress info 'Playing measure 'measure' Time: 'timer
- lister set handle newprogress bar 100 percent
- end
- end
- end
-
- call close('gm')
- lister clear handle progress
- lister set handle busy off